/* t6new.sas '/home/chansen/work/migration' CBH 8/8/02 */
/* Models include country fixed effects */
/* Uses distance from Pristina to nearest big city */

options linesize=78 compress=yes;

libname mydata 'DIRECTORY HERE';

proc sort data=mydata.bar_ent;
 by country;
run;

proc sort data=mydata.pristina out=temp;
 by country;

data bar_ent;
 merge mydata.bar_ent temp;
 by country;

data temp1;
 set mydata.rsa8399n;
run;

proc sort data=temp1;
 by country;
run;

data new8399;
 merge temp1 bar_ent;
 by country;

 nowarpr1=nowar*Sardis1/1000;
 nbospr1=nwbosnia*Sardis1/1000;
 nkospr1=nwkosovo*prdis1/1000;

 %macro years; lneu_lf1 d84 d85 d86 d87 d88 d89 d90 d91 d92 d93 d94 d95 d96 d97 d98 d99 %mend;
 %macro country; be dk de91 de_91 gr es fr ie it lu nl at pt fi se uk no is ch %mend;
 %macro ctrends; trendbe trendk trende91 trend_91 trendgr trendes trendfr trendie trendit
                 trendlu trendnl trendat trendpt trendfi trendse trenduk trendno trendis
                 trendch %mend;
 %macro inst1; nbospr1 nowarpr1 nkospr1 %mend;

 emp_prot=emp_prot-13;
 lab_stan=(lab_stan-5)/1.9518;
 rep_rate=(rep_rate-63)/17.70741;

 ep=(bar_ent-1.715)/.604373;

 NEU_ep=lnf_lf1*ep;
 NEU_ls=lnf_lf1*lab_stan;
 NEU_rr=lnf_lf1*rep_rate;

 nbos_ep=nbospr1*ep;
 nowar_ep=nowarpr1*ep;
 nkos_ep=nkospr1*ep;
 nbos_ls=nbospr1*lab_stan;
 nowar_ls=nowarpr1*lab_stan;
 nkos_ls=nkospr1*lab_stan;
 nbos_rr=nbospr1*rep_rate;
 nowar_rr=nowarpr1*rep_rate;
 nkos_rr=nkospr1*rep_rate;

 %macro instls; %inst1 nbos_ls nowar_ls nkos_ls %mend;
 %macro instrr; %inst1 nbos_rr nowar_rr nkos_rr %mend;
 %macro instlsrr; %inst1 nbos_ls nowar_ls nkos_ls nbos_rr nowar_rr nkos_rr %mend;
 %macro inst1b; nbosds12 noward12 nkosds12 nbos_ep nowar_ep nkos_ep %mend;
 %macro inst2b; %inst1b nbos_ls nowar_ls nkos_ls %mend;
 %macro inst3b; %inst2b nbos_rr nowar_rr nkos_rr %mend;

run;

proc datasets;
 delete temp1 bar_ent;
run;

**************************************************;
*            Labor Standards                     *;
**************************************************;

******************Men**************************;

proc syslin ols data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, LS';
 model lne_p = lnf_lf1 NEU_ls %years %country   dold;
run;
proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, LS';
 model lne_p = lnf_lf1 NEU_ls %years %country  ;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, LS';
 model lne_p = lnf_lf1 NEU_ls %years %country  ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, IV';
 endogenous lne_p lnf_lf1 NEU_ls;
 instruments %years %country  dold  %instls;
 model lne_p = lnf_lf1 NEU_ls %country  %years dold ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, IV';
 endogenous lne_p lnf_lf1 NEU_ls;
 instruments %years %country  %instls ;
 model lne_p = lnf_lf1 NEU_ls %country  %years ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, IV';
 endogenous lne_p lnf_lf1 NEU_ls;
 instruments %years %country  %instls ;
 model lne_p = lnf_lf1 NEU_ls %country  %years ;


************************************************;
*         Replacement Rate                     *;
************************************************;


******************Men**************************;

proc syslin ols data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, LS';
 model lne_p = lnf_lf1 NEU_rr %years %country   dold;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, LS';
 model lne_p = lnf_lf1 NEU_rr %years %country  ;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, LS';
 model lne_p = lnf_lf1 NEU_rr %years %country  ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, IV';
 endogenous lne_p lnf_lf1 NEU_rr;
 instruments %years %country  dold %instrr ;
 model lne_p = lnf_lf1 NEU_rr %country  %years dold ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, IV';
 endogenous lne_p lnf_lf1 NEU_rr;
 instruments %years %country  %instrr ;
 model lne_p = lnf_lf1 NEU_rr %country  %years ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, IV';
 endogenous lne_p lnf_lf1 NEU_rr;
 instruments %years %country  %instrr ;
 model lne_p = lnf_lf1 NEU_rr %country  %years ;



***********************************************;
*        Barriers to Entrepreneurship         *;
***********************************************;

******************Men**************************;

proc syslin ols data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, BE';
 model lne_p = lnf_lf1 NEU_ep %years %country   dold;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, BE';
 model lne_p = lnf_lf1 NEU_ep %years %country  ;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, BE';
 model lne_p = lnf_lf1 NEU_ep %years %country  ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, BE (IV)';
 endogenous lne_p lnf_lf1 NEU_ep;
 instruments %years %country  dold  %inst1b;
 model lne_p = lnf_lf1 NEU_ep %country  %years dold ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, BE (IV)';
 endogenous lne_p lnf_lf1 NEU_ep;
 instruments %years %country  %inst1b ;
 model lne_p = lnf_lf1 NEU_ep %country  %years ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, BE (IV)';
 endogenous lne_p lnf_lf1 NEU_ep;
 instruments %years %country  %inst1b ;
 model lne_p = lnf_lf1 NEU_ep %country  %years ;




***********************************************;
*        Rep. Rate and Lab. Standards         *;
***********************************************;

******************Men**************************;

proc syslin ols data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, LS,RR';
 model lne_p = lnf_lf1 NEU_ls NEU_rr %years %country   dold;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, LS,RR';
 model lne_p = lnf_lf1 NEU_ls NEU_rr %years %country  ;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, LS,RR';
 model lne_p = lnf_lf1 NEU_ls NEU_rr %years %country  ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, LS,RR (IV)';
 endogenous lne_p lnf_lf1 NEU_ls NEU_rr;
 instruments %years %country  dold  %instlsrr;
 model lne_p = lnf_lf1 NEU_ls NEU_rr %country  %years dold ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, LS,RR (IV)';
 endogenous lne_p lnf_lf1 NEU_ls NEU_rr;
 instruments %years %country  %instlsrr ;
 model lne_p = lnf_lf1 NEU_ls NEU_rr %country  %years ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, LS,RR (IV)';
 endogenous lne_p lnf_lf1 NEU_ls NEU_rr;
 instruments %years %country  %instlsrr ;
 model lne_p = lnf_lf1 NEU_ls NEU_rr %country  %years ;



***********************************************;
*        Barriers, Lab. Stan., Rep. Rate      *;
***********************************************;

******************Men**************************;

proc syslin ols data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, BE,LS,RR';
 model lne_p = lnf_lf1 NEU_ep NEU_ls NEU_rr %years %country   dold;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, BE,LS,RR';
 model lne_p = lnf_lf1 NEU_ep NEU_ls NEU_rr %years %country  ;

proc syslin ols data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, BE,LS,RR';
 model lne_p = lnf_lf1 NEU_ep NEU_ls NEU_rr %years %country  ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1;
 title '1983-99, all men with country effects, BE,LS,RR (IV)';
 endogenous lne_p lnf_lf1 NEU_ep NEU_ls NEU_rr;
 instruments %years %country  dold  %inst3b;
 model lne_p = lnf_lf1 NEU_ep NEU_ls NEU_rr %country  %years dold ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=0;
 title '1983-99, young men with country effects, BE,LS,RR (IV)';
 endogenous lne_p lnf_lf1 NEU_ep NEU_ls NEU_rr;
 instruments %years %country  %inst3b ;
 model lne_p = lnf_lf1 NEU_ep NEU_ls NEU_rr %country  %years ;

proc syslin 2sls data=new8399;
 where is=0 & dman=1 & dold=1;
 title '1983-99, old men with country effects, BE,LS,RR (IV)';
 endogenous lne_p lnf_lf1 NEU_ep NEU_ls NEU_rr;
 instruments %years %country  %inst3b ;
 model lne_p = lnf_lf1 NEU_ep NEU_ls NEU_rr %country  %years ;


run;
